/*
 * @lc app=leetcode.cn id=205 lang=javascript
 *
 * [205] 同构字符串
 */

// @lc code=start
/**
 * @param {string} s
 * @param {string} t
 * @return {boolean}
 */
var isIsomorphic = function (s, t) {
  let map1 = new Map();
  let map2 = new Map();
  for (let i = 0; i < s.length; i++) {
    const chS = s[i];
    const chT = t[i];
    if ((map1.has(chS) && map1.get(chS) != chT) || (map2.has(chT) && map2.get(chT) != chS)) {
      return false;
    }
    map1.set(chS, chT);
    map2.set(chT, chS);
  }

  return true;
};
// @lc code=end
